package com.zingrow.common.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;

import com.zingrow.web.configure.channel.model.Channel;
import com.zingrow.web.configure.domain.model.Domain;
import com.zingrow.web.configure.iformation.model.Iformation;
import com.zingrow.web.configure.keyword.model.Keyword;
import com.zingrow.web.configure.microuser.model.Microuser;
import com.zingrow.web.configure.weixin.model.Weixin;
import com.zingrow.web.customer.model.Group;
import com.zingrow.web.customer.model.GroupScheme;
import com.zingrow.web.report.model.RptModel;
import com.zingrow.web.report.model.RptModule;
import com.zingrow.web.report.model.RptModuleInfo;
import com.zingrow.web.support.operate.model.OptRecord;
import com.zingrow.web.support.operate.service.IOptRecordService;
import com.zingrow.web.support.operate.service.impl.OptRecordService;
import com.zingrow.web.thriftservice.Articles;
import com.zingrow.web.user.model.ActiveUser;
import com.zingrow.web.user.model.User;

public class OptClass {
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

	/*----------------------------------------用户管理------------------------------------------------------------------------*/
	/*
	 * 用户管理新增 user 新增用户对象 us 操作用户 men 模块 minmen 子模块 Operation 操作动作
	 */
	public OptRecord user_add(String groupname, User user, ActiveUser us, String men, String minmen, String Operation) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		// 操作行为
		s.setOptName("所属组织：(" + groupname + "),用户账号：(" + user.getUserAccount() + "),用户名称：(" + user.getUserName() + ")");
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		return s;
	}

	/*
	 * 用户管理修改 user 修改后的用户对象 Originaluser 原来的用户对象 us 操作用户 men 模块 minmen 子模块
	 * Operation 操作动作
	 */
	public OptRecord user_update(User user, User Originaluser, ActiveUser us, String men, String minmen,
			String Operation) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		// 操作行为
		String sv = "账号：" + Originaluser.getUserAccount() + "|";
		int leng = sv.length();
		// 判断所修改的内容
		if (!Originaluser.getGroupId().equals(user.getGroupId()))
			sv += "所属组织：(" + Originaluser.getGroupName() + ")->(" + user.getGroupName() + "),";
		if (!Originaluser.getUserAccount().equals(user.getUserAccount()))
			sv += "用户账号：(" + Originaluser.getUserAccount() + ")->(" + user.getUserAccount() + "),";
		if (!Originaluser.getUserName().equals(user.getUserName()))
			sv += "用户名称：(" + Originaluser.getUserName() + ")->(" + user.getUserName() + "),";
		if (!Originaluser.getUserPhone().equals(user.getUserPhone()))
			sv += "电话号码：(" + Originaluser.getUserPhone() + ")->(" + user.getUserPhone() + "),";
		if (!Originaluser.getUserMailbox().equals(user.getUserMailbox()))
			sv += "用户邮箱：(" + Originaluser.getUserMailbox() + ")->(" + user.getUserMailbox() + "),";
		if (user.getUserPwd() != null && !"".equals(user.getUserPwd()))
			sv += "密码被修改";
		if (sv.length() == leng)
			sv = null;
		s.setOptName(sv);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		return s;
	}

	/*
	 * 用户管理查询 us 操作用户 men 模块 minmen 子模块 Operation 操作动作 account 查询条件账号 name
	 * 查询条件名称 phone 查询条件电话 mailbox 查询条件邮箱 group 查询条件所属组织
	 */
	public OptRecord user_query(ActiveUser us, String men, String minmen, String Operation, String account, String name,
			String phone, String mailbox, String group) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		// 操作行为
		String sv = "条件|";
		int leng = sv.length();
		if (account != null && !"".equals(account))
			sv += "用户账号：" + account + ",";
		if (name != null && !"".equals(name))
			sv += "用户名称：" + name + ",";
		if (phone != null && !"".equals(phone))
			sv += "用户电话：" + phone + ",";
		if (mailbox != null && !"".equals(mailbox))
			sv += "用户邮箱：" + mailbox + ",";
		if (group != null && !"".equals(group))
			sv += "所属组织：" + group;
		if (sv.length() > leng) {
			s.setOptName(sv);
			s.setOptType(Operation);
			s.setUserAccount(us.getUserAccount());
			s.setUserId(us.getUserId());
			s.setInsertTime(new Date());
		} else
			s.setOptName("null");
		return s;
	}

	/*
	 * 修改信息方案权限 us 操作用户 men 模块 minmen 子模块 Operation 操作动作 account 改动用户账号
	 * 
	 */
	public OptRecord user_queryinformation(ActiveUser us, String men, String minmen, String Operation, String account,
			List<List<String>> list) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		// 操作内容
		String sv = "用户账号：" + account;
		/*
		 * if(list.get(2).size()>0){sv+="勾选方案：("; for(int
		 * i=0;i<list.get(2).size();i++) {sv+=list.get(2).get(i)+",";
		 * if(i==list.get(2).size()-1)sv+=")"; } }
		 * if(list.get(3).size()>0){sv+=",取消方案：("; for(int
		 * i=0;i<list.get(3).size();i++) {sv+=list.get(3).get(i)+",";
		 * if(i==list.get(3).size()-1)sv+=")"; } }
		 * if(list.get(2).size()==0&&list.get(3).size()==0)sv = null;
		 */
		s.setOptName(sv);
		return s;
	}

	/*
	 * 修改报告权限 us 操作用户 men 模块 minmen 子模块 Operation 操作动作 account 改动用户账号
	 * 
	 */
	public OptRecord user_queryPresentation(ActiveUser us, String men, String minmen, String Operation, String account,
			List<List<String>> list) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		// 操作内容
		String sv = "账号：" + account + "|";
		int leng = sv.length();
		if (list.get(0).size() > 0) {
			sv += "勾选报告：(";
			for (int i = 0; i < list.get(0).size(); i++) {
				if (list.get(0).get(i).equals("1"))
					sv += "日报,";
				else if (list.get(0).get(i).equals("2"))
					sv += "周报,";
				else if (list.get(0).get(i).equals("3"))
					sv += "月报,";
				if (i == list.get(0).size() - 1)
					sv += "),";
			}
		}
		if (list.get(1).size() > 0) {
			sv += "取消报告：(";
			for (int i = 0; i < list.get(1).size(); i++) {
				if (list.get(1).get(i).equals("1"))
					sv += "日报,";
				else if (list.get(1).get(i).equals("2"))
					sv += "周报,";
				else if (list.get(1).get(i).equals("3"))
					sv += "月报,";
				if (i == list.get(1).size() - 1)
					sv += ")";
			}
		}
		if (sv.length() == leng)
			sv = "null";
		s.setOptName(sv);
		return s;
	}

	/*
	 * 用户删除 us 操作用户 men 模块 minmen 子模块 Operation 操作动作 account 改动用户账号
	 * 
	 */
	public OptRecord user_delete(ActiveUser us, String men, String minmen, String Operation, String account) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		// 操作内容
		String sv = "用户账号：" + account;
		s.setOptName(sv);
		return s;
	}
	public OptRecord user_deletes(ActiveUser us, String men, String minmen, String Operation, String name) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		// 操作内容
		String sv =name;
		s.setOptName(sv);
		return s;
	}

	/*-----------------------------------------组织管理---------------------------------------------------------------------*/

	/*
	 * 组织管理查询 us 操作用户 men 模块 minmen 子模块 Operation 操作动作
	 * 
	 */
	public OptRecord group_query(ActiveUser us, String men, String minmen, String Operation, String groupname,
			String groupbrie) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		// 操作行为
		String sv = "条件|";
		int leng = sv.length();
		if (groupname != null && !"".equals(groupname))
			sv += "组织名称：" + groupname + ",";
		if (groupbrie != null && !"".equals(groupbrie))
			sv += "组织简称：" + groupbrie + ",";
		if (sv.length() > leng) {
			s.setOptName(sv);
			s.setOptType(Operation);
			s.setUserAccount(us.getUserAccount());
			s.setUserId(us.getUserId());
			s.setInsertTime(new Date());
		} else
			s.setOptName("null");
		return s;
	}

	/*
	 * 组织管理新增 user 新增组织对象 us 操作用户 men 模块 minmen 子模块 Operation 操作动作
	 */
	public OptRecord group_add(Group group, ActiveUser us, String men, String minmen, String Operation) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		// 操作行为
		s.setOptName("组织名称：" + group.getGroupName() + "组织简称：" + group.getGroupBrie());
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		return s;
	}

	/*
	 * 组织管理修改 group 修改后的组织对象 Originalgroup 原来的用户对象 us 操作用户 men 模块 minmen 子模块
	 * Operation 操作动作
	 */
	public OptRecord group_update(Group group, Group Originalgroup, ActiveUser us, String men, String minmen,
			String Operation) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		// 操作行为
		String sv = "组织：(" + Originalgroup.getGroupName() + "," + Originalgroup.getGroupBrie() + ")|";
		int leng = sv.length();
		// 判断所修改的内容
		if (!Originalgroup.getGroupName().equals(group.getGroupName()))
			sv += "组织名称：(" + Originalgroup.getGroupName() + ")->(" + group.getGroupName() + "),";
		if (!Originalgroup.getGroupBrie().equals(group.getGroupBrie()))
			sv += "组织简称：(" + Originalgroup.getGroupBrie() + ")->(" + group.getGroupBrie() + "),";
		if (!Originalgroup.getSchemeNum().equals(group.getSchemeNum()))
			sv += "栏目数：(" + Originalgroup.getSchemeNum() + ")->(" + group.getSchemeNum() + "),";
		if (!Originalgroup.getUserNum().equals(group.getUserNum()))
			sv += "用户数：(" + Originalgroup.getUserNum() + ")->(" + group.getUserNum() + "),";
		if (!Originalgroup.getGroupSketch().equals(group.getGroupSketch()))
			sv += "组织概述：(" + Originalgroup.getGroupSketch() + ")->(" + group.getGroupSketch() + "),";
		if (sv.length() == leng)
			sv = "null";
		s.setOptName(sv);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		return s;
	}

	/*
	 * 修改信息方案权限 us 操作用户 men 模块 minmen 子模块 Operation 操作动作
	 * 
	 */
	public OptRecord group_queryinformation(ActiveUser us, String men, String minmen, String Operation,
			String groupname, List<List<String>> list) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		// 操作内容
		String sv = "组织名称：" + groupname;
		/*
		 * if(list.get(2).size()>0){sv+="勾选方案：("; for(int
		 * i=0;i<list.get(2).size();i++) {sv+=list.get(2).get(i)+",";
		 * if(i==list.get(2).size()-1)sv+=")"; } }
		 * if(list.get(3).size()>0){sv+=",取消方案：("; for(int
		 * i=0;i<list.get(3).size();i++) {sv+=list.get(3).get(i)+",";
		 * if(i==list.get(3).size()-1)sv+=")"; } }
		 * 
		 * if(list.get(2).size()==0&&list.get(3).size()==0)sv = null;
		 */
		s.setOptName(sv);
		return s;
	}

	/*
	 * 修改敏感信息方案权限 us 操作用户 men 模块 minmen 子模块 Operation 操作动作
	 * 
	 */
	public OptRecord group_queryinformations(ActiveUser us, String men, String minmen, String Operation,
			String groupname, Iformation ifmname, Iformation rptifmname, List<GroupScheme> groups) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		/*
		 * int k=0; for(int i=0;i<groups.size();i++)
		 * if(groups.get(i).getIfmIsSensitivity()==1)k++;
		 */
		// 操作内容
		String sv = "组织：(" + groupname + ")|";
		/*
		 * int leng=sv.length(); if(ifmname!=null&&rptifmname!=null)
		 * sv+="敏感信息方案：("+ifmname.getIfm_name()+","+ifmname.getIfm_note()+")->("
		 * +rptifmname.getIfm_name()+","+rptifmname.getIfm_note()+")"; else
		 * if(ifmname==null&&rptifmname!=null)
		 * sv+="取消敏感信息方案：("+rptifmname.getIfm_name()+","+rptifmname.getIfm_note(
		 * )+")"; else if(ifmname!=null&&rptifmname==null&&k==0)
		 * sv+="新增敏感信息方案：("+ifmname.getIfm_name()+","+ifmname.getIfm_note()+")";
		 * if(sv.length()==leng)sv = null;
		 */
		s.setOptName(sv);
		return s;
	}

	/*
	 * 修改报告权限 us 操作用户 men 模块 minmen 子模块 Operation 操作动作
	 * 
	 */
	public OptRecord group_queryPresentation(ActiveUser us, String men, String minmen, String Operation,
			String groupname, String rptRight) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		// 操作内容
		String sv = "组织：(" + groupname + ")|";
		if (rptRight.equals("1"))
			sv += "开启报告权限！";
		else if (rptRight.equals("0"))
			sv += "关闭报告权限！";
		int leng = sv.length();
		s.setOptName(sv);
		return s;
	}

	/*
	 * 组织删除 us 操作用户 men 模块 minmen 子模块 Operation 操作动作 account 改动用户账号
	 * 
	 */
	public OptRecord group_delete(ActiveUser us, String men, String minmen, String Operation, String groupname) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		// 操作内容
		String sv = "组织名称：" + groupname;
		s.setOptName(sv);
		return s;
	}

	/*-----------------------------------------后台用户登录/登出---------------------------------------------------------------*/
	/*
	 * 用户登录/登出 us 操作用户 men 模块 minmen 子模块 Operation 操作动作
	 * 
	 */
	public OptRecord user_login(ActiveUser us, String men, String minmen, String Operation, String ip, String op) {
		OptRecord s = new OptRecord();
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		s.setOptChannel("");
		s.setOptminChannel("");
		s.setIp(ip);
		s.setRemarks(op);
		return s;
	}

	/*-----------------------------------------总库列表---------------------------------------------------------------------*/

	/*
	 * 信息管理新增 user 新增组织对象 us 操作用户 men 模块 minmen 子模块 Operation 操作动作
	 */
	public OptRecord final_add(Articles articles, ActiveUser us, String men, String minmen, String Operation) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		// 操作行为
		s.setOptName("信息标题：" + articles.getTitle());
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		return s;
	}

	/*
	 * 总库信息查询 us 操作用户 men 模块 minmen 子模块 Operation 操作动作
	 * 
	 */
	public OptRecord final_query(ActiveUser us, String men, String minmen, String Operation, Articles articles) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		// 操作行为
		String sv = "条件|";
		int leng = sv.length();
		if (articles.getTitle() != null && !"".equals(articles.getTitle()))
			sv += "标题：" + articles.getTitle() + ",";
		if (articles.getContent() != null && !"".equals(articles.getContent()))
			sv += "内容：" + articles.getContent() + ",";
		if (articles.getUrl() != null && !"".equals(articles.getUrl()))
			sv += "URL：" + articles.getUrl() + ",";
		if (articles.getSource() != null && !"".equals(articles.getSource()))
			sv += "首发媒体：" + articles.getSource() + ",";
		if (articles.getSeedType() != null && !"".equals(articles.getSeedType())) {
			if (articles.getSeedType().equals("News"))
				sv += "渠道：新闻,";
			if (articles.getSeedType().equals("BBS"))
				sv += "渠道：论坛,";
			if (articles.getSeedType().equals("WeiXin"))
				sv += "渠道：微信,";
			if (articles.getSeedType().equals("Micro"))
				sv += "渠道：微博,";
		}
		try {
			Date date1 = sdf.parse(articles.getPublishTimeFrom());
			Date date2 = sdf.parse(articles.getPublishTimeTo());
			Calendar cal = Calendar.getInstance();
			cal.setTime(date1);
			int year1 = cal.get(Calendar.YEAR);
			int month1 = cal.get(Calendar.MONTH);
			int day1 = cal.get(Calendar.DATE);
			cal.setTime(date2);
			int year2 = cal.get(Calendar.YEAR);
			int month2 = cal.get(Calendar.MONTH);
			int day2 = cal.get(Calendar.DATE);
			if (year1 != year2 || month1 != month2 || day1 != day2) {
				sv += "时间：" + articles.getPublishTimeFrom() + "-" + articles.getPublishTimeTo();
			}

		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if (sv.length() > leng) {
			s.setOptName(sv);
			s.setOptType(Operation);
			s.setUserAccount(us.getUserAccount());
			s.setUserId(us.getUserId());
			s.setInsertTime(new Date());
		} else
			s.setOptName("null");
		return s;
	}

	/*
	 * 总库列表修改 us 操作用户 men 模块 minmen 子模块 Operation 操作动作
	 * 
	 */
	public OptRecord final_update(ActiveUser us, String men, String minmen, String Operation, String title, int i) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		// 操作内容
		String sv = "";
		if (i == 1)
			sv = "原文链接：" + title;
		else
			sv = "信息标题：" + title;

		s.setOptName(sv);
		return s;
	}

	/*
	 * 总库列表删除 us 操作用户 men 模块 minmen 子模块 Operation 操作动作
	 * 
	 */
	public OptRecord final_delete(ActiveUser us, String men, String minmen, String Operation, String title, String sw) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		// 操作内容
		String sv = "";
		if (sw.equals("1"))
			sv = "信息标题：" + title;
		if (sw.equals("2"))
			sv = "博主URL：" + title;
		s.setOptName(sv);
		return s;
	}
	/*-------------------------------------------已发布信息列表-------------------------------------------------------------*/

	/*
	 * yifabu信息查询 us 操作用户 men 模块 minmen 子模块 Operation 操作动作
	 * 
	 */
	public OptRecord dist_query(ActiveUser us, String men, String minmen, String Operation, String title,
			String content, String websiteName, String articleType, String url, String ifmIdd, String groupId,
			String releaseTime1, String releaseTime2) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		// 操作行为
		String sv = "条件|";
		int leng = sv.length();
		if (title != null && !"".equals(title))
			sv += "标题：" + title + ",";
		if (content != null && !"".equals(content))
			sv += "内容：" + content + ",";
		if (url != null && !"".equals(url))
			sv += "URL：" + url + ",";
		if (websiteName != null && !"".equals(websiteName))
			sv += "首发媒体：" + websiteName + ",";
		if (articleType != null && !"".equals(articleType)) {
			if (articleType.equals("News"))
				sv += "渠道：新闻,";
			if (articleType.equals("BBS"))
				sv += "渠道：论坛,";
			if (articleType.equals("WeiXin"))
				sv += "渠道：微信,";
			if (articleType.equals("Micro"))
				sv += "渠道：微博,";
		}
		if (groupId != null && !"".equals(groupId))
			sv += "所属组织：" + groupId + ",";
		if (ifmIdd != null && !"".equals(ifmIdd))
			sv += "所属信息方案：" + ifmIdd + ",";
		try {
			Date date1 = sdf.parse(releaseTime1);
			Date date2 = sdf.parse(releaseTime2);
			Calendar cal = Calendar.getInstance();
			cal.setTime(date1);
			int year1 = cal.get(Calendar.YEAR);
			int month1 = cal.get(Calendar.MONTH);
			int day1 = cal.get(Calendar.DATE);
			cal.setTime(date2);
			int year2 = cal.get(Calendar.YEAR);
			int month2 = cal.get(Calendar.MONTH);
			int day2 = cal.get(Calendar.DATE);
			if (year1 != year2 || month1 != month2 || day1 != day2) {
				sv += "时间：" + releaseTime1 + "-" + releaseTime2;
			}

		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if (sv.length() > leng) {
			s.setOptName(sv);
			s.setOptType(Operation);
			s.setUserAccount(us.getUserAccount());
			s.setUserId(us.getUserId());
			s.setInsertTime(new Date());
		} else
			s.setOptName("null");
		return s;
	}

	/*
	 * 已发布列表删除 us 操作用户 men 模块 minmen 子模块 Operation 操作动作
	 * 
	 */
	public OptRecord dist_delete(ActiveUser us, String men, String minmen, String Operation, String title, String t) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		// 操作内容
		String sv = "";
		if ("1".equals(t))
			sv = "信息标题：" + title;
		else if ("2".equals(t))
			sv = "博主URL：" + title;
		s.setOptName(sv);
		return s;
	}

	/*
	 * 编辑信息方案 us 操作用户 men 模块 minmen 子模块 Operation 操作动作
	 * 
	 */
	public OptRecord dist_ifm(ActiveUser us, String men, String minmen, String Operation, String title, String name2) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		// 操作内容
		String sv = "删除信息(" + name2 + ")与方案(" + title + ")之间的关系";
		s.setOptName(sv);
		return s;
	}

	/*
	 * 已发布修改 us 操作用户 men 模块 minmen 子模块 Operation 操作动作
	 * 
	 */
	public OptRecord dist_Update(ActiveUser us, String men, String minmen, String Operation, String title, int i) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		// 操作内容
		String sv = "";
		if (i == 1)
			sv = "原文链接：" + title;
		else
			sv = "信息标题：" + title;
		s.setOptName(sv);
		return s;
	}
	/*-------------------------------------信息方案配置---------------------------------------------------------------------*/

	/*
	 * 信息方案配置查询 us 操作用户 men 模块 minmen 子模块 Operation 操作动作
	 * 
	 */
	public OptRecord messfim_query(ActiveUser us, String men, String minmen, String Operation, String ifm_name,
			String ifm_note, String groupname, String ifm_isdelete, String ifm_categoryName

	) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH：mm：ss");
		// 操作行为
		String sv = "条件|";
		int leng = sv.length();
		if (ifm_name != null && !"".equals(ifm_name))
			sv += "方案名称：" + ifm_name + ",";
		if (ifm_note != null && !"".equals(ifm_note))
			sv += "方案备注：" + ifm_note + ",";
		if (groupname != null && !"".equals(groupname))
			sv += "组织名称：" + groupname + ",";
		if (ifm_isdelete != null && !"".equals(ifm_isdelete))
			sv += "方案状态：" + ifm_isdelete + ",";
		if (ifm_categoryName != null && !"".equals(ifm_categoryName))
			sv += "所属类别名称：" + ifm_categoryName + ",";
		if (sv.length() > leng) {
			s.setOptName(sv);
			s.setOptType(Operation);
			s.setUserAccount(us.getUserAccount());
			s.setUserId(us.getUserId());
			s.setInsertTime(new Date());
		} else
			s.setOptName("null");
		return s;
	}

	/*
	 * 方案信息管理新增 user 新增组织对象 us 操作用户 men 模块 minmen 子模块 Operation 操作动作
	 */
	public OptRecord messfim_add(ActiveUser us, String men, String minmen, String Operation, String ifmname,
			String ifmnot) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		// 操作行为
		s.setOptName("信息方案名称：" + ifmname + ",信息方案备注：" + ifmnot);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		return s;
	}

	/*
	 * 方案信息管理修改 us 操作用户 men 模块 minmen 子模块 Operation 操作动作
	 */
	public OptRecord messfim_update(Iformation iformation, Iformation iformation2, ActiveUser us, String men,
			String minmen, String Operation, String oldCategory, String oldCategoryName) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		// 操作行为
		String sv = "方案：(" + iformation.getIfm_name() + ")|";
		int leng = sv.length();
		// 判断所修改的内容
		if (!iformation.getIfm_name().equals(iformation2.getIfm_name()))
			sv += "方案名称：(" + iformation2.getIfm_name() + ")->(" + iformation.getIfm_name() + "),";
		if (!iformation.getIfm_note().equals(iformation2.getIfm_note()))
			sv += "方案备注：(" + iformation2.getIfm_note() + ")->(" + iformation.getIfm_note() + "),";
		if (iformation.getIfm_pushed() != iformation2.getIfm_pushed()) {
			String s1 = "", s2 = "";
			if (iformation.getIfm_pushed() == 0)
				s1 = "否";
			else if (iformation.getIfm_pushed() == 1)
				s1 = "是";
			if (iformation2.getIfm_pushed() == 0)
				s2 = "否";
			else if (iformation2.getIfm_pushed() == 1)
				s2 = "是";
			sv += "是否推送：(" + s2 + ")->(" + s1 + "),";
		}
		if (iformation.getIfm_pushed() == 1 && iformation2.getIfm_pushed() != 1) {
			String s1 = "", s2 = "";
			/*
			 * if(iformation.getIfm_type().equals("app"))s1="手机"; else
			 * if(iformation.getIfm_type().equals("note"))s1="短信"; else
			 * if(iformation.getIfm_type().equals("None"))s1="无"; else s1="无";
			 */
			String[] st = iformation.getIfm_type().split("\\|");
			if (st.length != 2) {
				if (st[0].equals("app"))
					s2 = "手机";
				else if (st[0].equals("note"))
					s2 = "短信";
				else if (st[0].equals("None"))
					s2 = "无";
				else
					s2 = "无";
				sv += "推送方式：" + s2 + ",";
			} else {
				sv += "推送方式：(手机,短信),";
			}
		}
		if (oldCategory != null) {
			if (iformation.getIfm_category().equals(oldCategory))
				sv += "仅修改类别名称：" + oldCategory + "(" + oldCategoryName + "->" + iformation.getIfm_categoryName() + "),";
			else
				sv += "修改类别：(" + oldCategory + "," + oldCategoryName + ")->(" + iformation.getIfm_category() + ","
						+ iformation.getIfm_categoryName() + "),";
		}
		if (sv.length() == leng)
			sv = "null";
		s.setOptName(sv);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		return s;
	}

	/*
	 * 方案管理删除/编辑信息方案 us 操作用户 men 模块 minmen 子模块 Operation 操作动作
	 * 
	 */
	public OptRecord messfim_delete(ActiveUser us, String men, String minmen, String Operation, String name) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		// 操作内容
		String sv = "";
		sv = "方案名称：" + name;
		s.setOptName(sv);
		return s;
	}

	/*
	 * 资源编辑 us 操作用户 men 模块 minmen 子模块 Operation 操作动作 iformation 操作后 iformation2
	 * 操作前
	 * 
	 */
	public OptRecord messfim_zhiyuanbj(Iformation iformation, Iformation iformation2, ActiveUser us, String men,
			String minmen, String Operation) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		// 操作内容
		String sv = "";
		sv = "方案名称：" + iformation.getIfm_name() + "|";
		int leng = sv.length();
		if (!iformation2.getIfm_getChannel().equals(iformation.getIfm_getChannel())
				|| !iformation.getIfm_notChannel().equals(iformation2.getIfm_notChannel())) {
			sv += "频道资源变更,";
		}
		if (!iformation2.getIfm_getWechatId().equals(iformation.getIfm_getWechatId())
				|| !iformation.getIfm_notWechatId().equals(iformation2.getIfm_notWechatId())) {
			sv += "微信资源变更,";
		}
		if (!iformation2.getIfm_getBloggerId().equals(iformation.getIfm_getBloggerId())
				|| !iformation.getIfm_notBloggerId().equals(iformation2.getIfm_notBloggerId())) {
			sv += "微博资源变更,";
		}
		if (!iformation2.getIfm_getBbsName().equals(iformation.getIfm_getBbsName())
				|| !iformation.getIfm_notBbsName().equals(iformation2.getIfm_notBbsName())) {
			sv += "论坛资源变更,";
		}
		if (sv.length() == leng)
			sv = "null";
		s.setOptName(sv);
		return s;
	}

	/*
	 * 关键词编辑 us 操作用户 men 模块 minmen 子模块 Operation 操作动作 iformation 操作后 iformation2
	 * 操作前
	 * 
	 */
	public OptRecord messfim_guanjianbj(Iformation iformation, Iformation iformation2, ActiveUser us, String men,
			String minmen, String Operation) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		// 操作内容
		String sv = "";
		sv = "方案名称：" + iformation.getIfm_name() + "|";
		int leng = sv.length();
		if (!iformation.getIfm_getKeyword().equals(iformation2.getIfm_getKeyword()))
			sv += "匹配关键词变更,";
		if (!iformation.getIfm_notKeyword().equals(iformation2.getIfm_notKeyword()))
			sv += "过滤关键词变更,";
		if (sv.length() == leng)
			sv = "null";
		s.setOptName(sv);
		return s;
	}

	/*
	 * 开启关闭 us 操作用户 men 模块 minmen 子模块 Operation 操作动作 iformation 操作后 iformation2
	 * 操作前
	 * 
	 */
	public OptRecord messfim_gonot(Iformation iformation, Iformation iformation2, ActiveUser us, String men,
			String minmen, String Operation) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		// 操作内容
		String sv = "";
		sv = "方案名称：" + iformation.getIfm_name() + "|";
		int leng = sv.length();
		if (!iformation.getIfm_isdelete().equals(iformation2.getIfm_isdelete())) {
			if (iformation.getIfm_isdelete() == 1)
				sv += "开启方案,";
			else if (iformation.getIfm_isdelete() == 0)
				sv += "关闭方案,";
		}
		if (sv.length() == leng)
			sv = "null";
		s.setOptName(sv);
		return s;
	}
	/*---------------------------------------微博配置模块---------------------------------------------------------------------*/

	/* 删除 */
	public OptRecord weibo_delete(ActiveUser us, String men, String minmen, String Operation, Microuser ymicrouser) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		s.setOptName("微博ID：" + ymicrouser.getMicrouser_bloggerId());
		return s;
	}

	/* 查询 */
	public OptRecord weibo_query(ActiveUser us, String men, String minmen, String Operation, String microuser_bloggerId,
			String microuser_blogger, String microuser_bloggerUrl) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		String sv = "条件：";
		int leng = sv.length();
		if (microuser_bloggerId != null && !microuser_bloggerId.equals(""))
			sv += "微博ID：" + microuser_bloggerId + ",";
		if (microuser_blogger != null && !microuser_blogger.equals(""))
			sv += "微主用户名：" + microuser_blogger + ",";
		if (microuser_bloggerUrl != null && !microuser_bloggerUrl.equals(""))
			sv += "博主URL：" + microuser_bloggerUrl + ",";

		if (leng == sv.length())
			sv = "null";
		s.setOptName(sv);
		return s;
	}

	/* 新增 */
	public OptRecord weibo_add(ActiveUser us, String men, String minmen, String Operation, Microuser microuser) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		String sv = "微博ID：" + microuser.getMicrouser_bloggerId() + ",博主用户名：" + microuser.getMicrouser_blogger();
		s.setOptName(sv);
		return s;
	}

	/* 修改 */
	public OptRecord weibo_updata(ActiveUser us, String men, String minmen, String Operation, Microuser ymicrouser,
			Microuser microuser) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		String S1 = "", S2 = "";
		String sv = "修改：";
		if (!ymicrouser.getMicrouser_bloggerId().equals(microuser.getMicrouser_bloggerId()))
			sv += "微博ID：(" + microuser.getMicrouser_bloggerId() + ")->(" + microuser.getMicrouser_bloggerId() + "),";
		if (!ymicrouser.getMicrouser_blogger().equals(microuser.getMicrouser_blogger()))
			sv += "博主用户名：(" + ymicrouser.getMicrouser_blogger() + ")->(" + microuser.getMicrouser_blogger() + "),";
		if (!ymicrouser.getMicrouser_bloggerUrl().equals(microuser.getMicrouser_bloggerUrl()))
			sv += "博主URL：(" + ymicrouser.getMicrouser_bloggerUrl() + ")->(" + microuser.getMicrouser_bloggerUrl()
					+ "),";
		int leng = sv.length();
		s.setOptName(sv);
		return s;
	}
	/*---------------------------------------站点配置模块---------------------------------------------------------------------*/

	/* 删除 */
	public OptRecord zd_delete(ActiveUser us, String men, String minmen, String Operation, String channelname) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		s.setOptName("站点名称：" + channelname);
		return s;
	}

	/* 查询 */
	public OptRecord zd_query(ActiveUser us, String men, String minmen, String Operation, String domain_name,
			String domain_domain, String domain_category) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		String sv = "条件：";
		int leng = sv.length();
		if (domain_name != null && !domain_name.equals(""))
			sv += "站点名称：" + domain_name + ",";
		if (domain_domain != null && !domain_domain.equals(""))
			sv += "站点url：" + domain_domain + ",";
		if (domain_category != null && !domain_category.equals("")) {
			if (domain_category.equals("News"))
				sv += "站点类型：新闻,";
			else
				sv += "站点类型：论坛,";
		}
		if (leng == sv.length())
			sv = "null";
		s.setOptName(sv);
		return s;
	}

	/* 新增 */
	public OptRecord zd_add(ActiveUser us, String men, String minmen, String Operation, Domain domain) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		String sv = "站点名称：" + domain.getDomain_name() + ",站点url：" + domain.getDomain_domain();
		s.setOptName(sv);
		return s;
	}

	/* 修改 */
	public OptRecord zd_updata(ActiveUser us, String men, String minmen, String Operation, Domain ydomain,
			Domain domain) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		String S1 = "", S2 = "";
		if (ydomain.getDomain_domain().equals("News"))
			S1 = "新闻";
		else
			S1 = "论坛";
		if (domain.getDomain_domain().equals("News"))
			S2 = "新闻";
		else
			S2 = "论坛";
		String sv = "修改：";
		if (!ydomain.getDomain_name().equals(domain.getDomain_name()))
			sv += "站点名称：(" + ydomain.getDomain_name() + ")->(" + domain.getDomain_name() + "),";
		if (!ydomain.getDomain_category().equals(domain.getDomain_category()))
			sv += "站点url：(" + ydomain.getDomain_category() + ")->(" + domain.getDomain_category() + "),";
		if (!ydomain.getDomain_domain().equals(domain.getDomain_domain()))
			sv += "站点类型：(" + S1 + ")->(" + S2 + "),";
		int leng = sv.length();
		s.setOptName(sv);
		return s;
	}
	/*---------------------------------------微信配置模块---------------------------------------------------------------------*/

	/* 删除 */
	public OptRecord weixin_delete(ActiveUser us, String men, String minmen, String Operation, String weixin) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		s.setOptName("微信号：" + weixin);
		return s;
	}

	/* 查询 */
	public OptRecord weixin_query(ActiveUser us, String men, String minmen, String Operation, String weixinuser_Id,
			String weixin_name) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		String sv = "条件：";
		int leng = sv.length();
		if (weixinuser_Id != null && !weixinuser_Id.equals(""))
			sv += "微信号：" + weixinuser_Id + ",";
		if (weixin_name != null && !weixin_name.equals(""))
			sv += "微信名：" + weixin_name + ",";
		if (leng == sv.length())
			sv = "null";
		s.setOptName(sv);
		return s;
	}

	/* 新增 */
	public OptRecord weixin_add(ActiveUser us, String men, String minmen, String Operation, Weixin weixin) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		String sv = "微信号：" + weixin.getWeixinuser_Id() + ",微信名：" + weixin.getWeixin_name();
		s.setOptName(sv);
		return s;
	}

	/* 修改 */
	public OptRecord weixin_updata(ActiveUser us, String men, String minmen, String Operation, Weixin yweixin,
			Weixin weixin) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		String sv = "修改：";
		if (!yweixin.getWeixinuser_Id().equals(weixin.getWeixinuser_Id()))
			sv += "微信号：(" + yweixin.getWeixinuser_Id() + ")->(" + weixin.getWeixinuser_Id() + "),";
		if (!yweixin.getWeixin_name().equals(weixin.getWeixin_name()))
			sv += "微信名：(" + yweixin.getWeixin_name() + ")->(" + weixin.getWeixin_name() + "),";
		int leng = sv.length();
		s.setOptName(sv);
		return s;
	}
	/*---------------------------------------频道配置模块---------------------------------------------------------------------*/

	/* 删除 */
	public OptRecord channel_delete(ActiveUser us, String men, String minmen, String Operation, String channelname) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		s.setOptName("频道名称：" + channelname);
		return s;
	}

	/* 查询 */
	public OptRecord channel_query(ActiveUser us, String men, String minmen, String Operation, String channelname,
			String channelurl, String channeltype) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		String sv = "条件：";
		int leng = sv.length();
		if (channelname != null && !channelname.equals(""))
			sv += "频道名称：" + channelname + ",";
		if (channelurl != null && !channelurl.equals(""))
			sv += "频道url：" + channelurl + ",";
		if (channeltype != null && !channeltype.equals("")) {
			if (channeltype.equals("News"))
				sv += "频道类型：新闻,";
			else
				sv += "频道类型：论坛,";
		}
		if (leng == sv.length())
			sv = "null";
		s.setOptName(sv);
		return s;
	}

	/* 新增 */
	public OptRecord channel_add(ActiveUser us, String men, String minmen, String Operation, Channel channel) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		String sv = "频道名称：" + channel.getChannel_name() + ",频道url：" + channel.getChannel_url();
		s.setOptName(sv);
		return s;
	}

	/* 修改 */
	public OptRecord channel_updata(ActiveUser us, String men, String minmen, String Operation, Channel ychannel,
			Channel channel, Domain name1, Domain name2) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		String S1 = "", S2 = "";
		if (ychannel.getChannel_type().equals("News"))
			S1 = "新闻";
		else
			S1 = "论坛";
		if (channel.getChannel_type().equals("News"))
			S2 = "新闻";
		else
			S2 = "论坛";
		String sv = "修改：";
		int leng = sv.length();
		if (null == name1 && null != name2.getDomain_name())
			sv = "所属站点：(无)->(" + name2.getDomain_name() + "),";
		else if (null != name1.getDomain_name() && null != name2.getDomain_name())
			sv = "所属站点：(" + name1.getDomain_name() + ")->(" + name2.getDomain_name() + "),";
		if (!ychannel.getChannel_name().equals(channel.getChannel_name()))
			sv += "频道名称：(" + ychannel.getChannel_name() + ")->(" + channel.getChannel_name() + "),";
		if (!ychannel.getChannel_url().equals(channel.getChannel_url()))
			sv += "频道url：(" + ychannel.getChannel_url() + ")->(" + channel.getChannel_url() + "),";
		if (!ychannel.getChannel_type().equals(channel.getChannel_type()))
			sv += "频道类型：(" + S1 + ")->(" + S2 + "),";
		if (sv.length() == leng)
			sv = "null";
		s.setOptName(sv);
		return s;
	}
	/*---------------------------------------远搜索配置模块---------------------------------------------------------------------*/

	/* 删除 */
	public OptRecord yss_delete(ActiveUser us, String men, String minmen, String Operation, Keyword keyword) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		s.setOptName("关键字：" + keyword.getKeywords_seek() + ",引擎：" + keyword.getKeywords_type());
		return s;
	}

	/* 查询 */
	public OptRecord yss_query(ActiveUser us, String men, String minmen, String Operation, String keywords_seek) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		String sv = "条件：";
		int leng = sv.length();
		if (keywords_seek != null && !keywords_seek.equals(""))
			sv += "关键词：" + keywords_seek + ",";
		if (leng == sv.length())
			sv = "null";
		s.setOptName(sv);
		return s;
	}

	/* 新增 */
	public OptRecord yss_add(ActiveUser us, String men, String minmen, String Operation, Keyword keyword) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		String sv = "关键词：" + keyword.getKeywords_seek() + ",引擎：" + keyword.getKeywords_type();
		s.setOptName(sv);
		return s;
	}

	/* 修改 */
	public OptRecord yss_updata(ActiveUser us, String men, String minmen, String Operation, Keyword ykeyword,
			Keyword keyword) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		String sv = "修改：";
		if (!ykeyword.getKeywords_seek().equals(keyword.getKeywords_seek()))
			sv += "关键词：(" + ykeyword.getKeywords_seek() + ")->(" + keyword.getKeywords_seek() + "),";
		if (!ykeyword.getKeywords_type().equals(keyword.getKeywords_type()))
			sv += "引擎：(" + ykeyword.getKeywords_type() + ")->(" + keyword.getKeywords_type() + "),";
		int leng = sv.length();
		s.setOptName(sv);
		return s;
	}

	/*-----------------------------------------报告模板配置-----------------------------------------------------------------*/

	/* 查询 */
	public OptRecord report_query(ActiveUser us, String men, String minmen, String Operation, String name,
			String groupname, Integer cycleId) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		String sv = "条件：";
		int leng = sv.length();
		if (name != null && !name.equals(""))
			sv += "报告模板名称：" + name + ",";
		if (groupname != null && !groupname.equals(""))
			sv += "报告所属组织：" + groupname + ",";
		if (cycleId != null) {
			if (cycleId == 1)
				sv += "报告周期：日报,";
			else if (cycleId == 2)
				sv += "报告周期：周报,";
			else if (cycleId == 3)
				sv += "报告周期：月报,";
		}
		if (leng == sv.length())
			sv = "null";
		s.setOptName(sv);
		return s;
	}

	/* 新增 */
	public OptRecord report_add(ActiveUser us, String men, String minmen, String Operation, RptModel rptmodel,
			String group) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		String sv = "所属组织：" + group + ",报告周期：" + rptmodel.getName();
		s.setOptName(sv);
		return s;
	}

	/* 修改 */
	public OptRecord report_updata(ActiveUser us, String men, String minmen, String Operation,
			List<RptModuleInfo> ylist, List<RptModuleInfo> list, List<RptModule> slist, String name, String groupname) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		List<String> x1 = new ArrayList<String>();
		List<String> x2 = new ArrayList<String>();
		List<String> kk = new ArrayList<String>();
		for (int i = 0; i < ylist.size(); i++)
			x1.add(ylist.get(i).getModuleId().toString() + "," + ylist.get(i).getPlanId());
		for (int i = 0; i < list.size(); i++)
			x2.add(list.get(i).getModuleId().toString() + "," + list.get(i).getPlanId());
		Set<String> set1 = new HashSet<String>();
		Set<String> set2 = new HashSet<String>();
		for (int i = 0; i < x1.size(); i++)
			set1.add(x1.get(i));
		for (int i = 0; i < x2.size(); i++)
			if (set1.add(x2.get(i))) {
				kk.add(x2.get(i));
			}
		for (int i = 0; i < x2.size(); i++)
			set2.add(x2.get(i));
		for (int i = 0; i < x1.size(); i++)
			if (set2.add(x1.get(i))) {
				kk.add(x1.get(i));
			}
		String sv = "修改组织(" + groupname + ")的(" + name + "),修改了模块：";
		int leng = sv.length();
		Set<String> goog = new HashSet<String>();
		for (int i = 0; i < kk.size(); i++) {
			String[] ks = kk.get(i).split(",");
			goog.add(ks[0]);
		}
		for (String set : goog) {
			for (int k = 0; k < slist.size(); k++) {
				if (slist.get(k).getId().toString().equals(set)) {
					sv += slist.get(k).getName() + ",";
				}
			}
		}
		if (sv.length() == leng)
			sv = "null";
		s.setOptName(sv);
		return s;
	}

	/* 游览/开启关闭 */
	public OptRecord report_add(ActiveUser us, String men, String minmen, String Operation, RptModel rptModel,
			String sw1, String sw2) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		String sv = "";
		if (sw1.equals("null")) {
			if (rptModel.getIsOpen() == 1)
				sv = "开启组织：(" + rptModel.getName() + ")的(" + rptModel.getNote() + ")生成。";
			else
				sv = "关闭组织：(" + rptModel.getName() + ")的(" + rptModel.getNote() + ")生成。";
		} else {

		}
		s.setOptName(sv);
		return s;
	}

	/*-----------------------------------------报告配置-----------------------------------------------------------------*/

	/* 查询 */
	public OptRecord reports_query(ActiveUser us, String men, String minmen, String Operation, String name,
			String groupname, Integer CycleId, String username, Date releaseTime1, Date releaseTime2) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		String sv = "条件：";
		int leng = sv.length();
		if (name != null && !name.equals(""))
			sv += "报告名称：" + name + ",";
		if (groupname != null && !groupname.equals(""))
			sv += "所属组织：" + groupname + ",";
		if (username != null && !username.equals(""))
			sv += "所属用户：" + username + ",";
		if (CycleId != null) {
			if (CycleId == 1)
				sv += "报告周期：日报,";
			else if (CycleId == 2)
				sv += "报告周期：周报,";
			else if (CycleId == 3)
				sv += "报告周期：月报,";
		}
		SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyy-MM-dd");
		if (releaseTime1 != null && !"".equals(releaseTime1))
			sv += "生成时间：(" + bartDateFormat.format(releaseTime1) + ")->(" + bartDateFormat.format(releaseTime2) + "),";
		if (leng == sv.length())
			sv = "null";
		s.setOptName(sv);
		return s;
	}

	/* 删除 */
	public OptRecord reports_delete(ActiveUser us, String men, String minmen, String Operation, String name,
			String groupName) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		String sv = "报告名称：" + name + ",所属组织：" + groupName;
		s.setOptName(sv);
		return s;
	}

	/* 游览/导出/下载/ */
	public OptRecord reports_adds(ActiveUser us, String men, String minmen, String Operation, String sw1) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		s.setOptName(sw1);
		return s;
	}

	/*-----------------------------------------通用方法---------------------------------------------------------------------*/
	/*
	 * 统计开始和结束两个数组增加和减少的元素
	 */
	public List<List<String>> comparearray(String[] startlist, String[] endlist) {
		List<List<String>> list = new ArrayList<List<String>>();
		Set<String> a = new HashSet<>();
		Set<String> b = new HashSet<>();
		List<String> many = new ArrayList<String>();
		List<String> less = new ArrayList<String>();
		if (startlist.length > 0) {
			for (int i = 0; i < startlist.length; i++)
				a.add(startlist[i]);

			for (int i = 0; i < endlist.length; i++) {
				if (a.add(endlist[i]))
					many.add(endlist[i]);
				else
					b.add(endlist[i]);
			}
			for (int i = 0; i < startlist.length; i++)
				if (b.add(startlist[i]))
					less.add(startlist[i]);
		} else {
			for (int i = 0; i < endlist.length; i++) {
				if (a.add(endlist[i]))
					many.add(endlist[i]);
			}
		}
		list.add(many);
		list.add(less);
		return list;
	}

	/* 记录异常 */
	public OptRecord recordabnormality(ActiveUser us, String opt) {
		OptRecord s = new OptRecord();
		s.setUserId(us.getUserId());
		s.setUserAccount(us.getUserAccount());
		s.setRemarks(opt);
		return s;
	}

	/**/
	public OptRecord goiss(ActiveUser us, String men, String minmen, String Operation, int size) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		if (size == 0)
			s.setOptName("");
		else
			s.setOptName(Operation + "数目为" + size);
		return s;
	}

	/* 模板下载 */
	public OptRecord modelxz(ActiveUser us, String men, String minmen, String Operation, String xz) {
		OptRecord s = new OptRecord();
		s.setOptChannel(men);
		s.setOptminChannel(minmen);
		s.setOptType(Operation);
		s.setUserAccount(us.getUserAccount());
		s.setUserId(us.getUserId());
		s.setInsertTime(new Date());
		s.setOptName(xz);
		return s;
	}

}
